<template>
  <div class="singer_same">
    <div class="singer_wrap">
      <div
        v-for="(item, index) in singerList.slice(0, 12)"
        :key="index"
        class="item"
      >
        <div class="cover">
          <el-image
            lazy
            @click="toDetail(item.id)"
            :src="item.img1v1Url"
            fit="cover"
          ></el-image>
        </div>
        <div class="name">{{ item.name }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { getSingerSame } from "@/util/music.js";
export default {
  name: "Singersame",

  data() {
    return {
      singerId: this.$route.params.id,
      singerList: [],
    };
  },

  created() {
    this.getSingerSame();
  },

  methods: {
    //获取相似歌手
    async getSingerSame() {
      let { data } = await getSingerSame(this.singerId);
      // console.log(data);
      this.singerList = data.artists;
    },
    //跳转至歌手详情
    toDetail(id) {
      this.$router.push("/singerInfo/" + id);
    },
  },
};
</script>

<style lang="less" scoped>
.singer_wrap {
  margin: 40px 0;
  display: grid;
  justify-content: space-around;
  align-content: center;
  grid-template-columns: repeat(auto-fill, 15rem);
  .item {
    text-align: center;
    margin-bottom: 20px;
    overflow: hidden;
    // height: 15rem;
      .el-image {
        height: 100%;
        border-radius: 50%;
      }
    .name {
      font-size: 18px;
      font-weight: 600;
      margin-top: 10px;
    }
  }
}
</style>